require 'migration_helpers'

class CreateAddresses < ActiveRecord::Migration
  extend MigrationHelper::ForeignKeys
  
  def self.up
    create_table :addresses do |t|
      t.column :street, :string
      t.column :city, :string
      t.column :state_id, :int                      #FK
      t.column :zipcode, :string, :limit => 5
      t.column :telephone, :string, :limit => 10
      t.column :fax, :string, :limit => 10
      t.column :created_at, :datetime
      t.column :updated_at, :datetime
    end
    
    add_foreign_key(:addresses, :state_id, :states)
  end

  def self.down
    drop_table :addresses
  end
end
